package controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import service.BookService;
import vo.Book;

@Controller
public class BookContoller {
	@Autowired
	private BookService bs;
	@ResponseBody
	@RequestMapping(value="book",method=RequestMethod.POST)
	public Book addBook(@RequestBody Book book){
		return bs.addBook(book);
	}
	@ResponseBody
	@RequestMapping(value="book",method=RequestMethod.GET)
	public List<Book> findAllBooks(){
		return bs.findAllBooks();
	}
	@ResponseBody
	@RequestMapping(value="book/{id}",method=RequestMethod.DELETE)
	public  void deleteBook(@PathVariable int id){
		bs.deleteBook(id);
	}
}
